<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试</title>

<%@ include file="/template.jsp" %>
<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>

</head>
<body>
	
	<input type="text" id="timestamp" value="${validation.timestamp}" />
	<input type="text" id="nonceStr" value="${validation.nonceStr}" />
	<input type="text" id="signature" value="${validation.signature}" />
	<input type="text" id="appId" value="${validation.appId}" />

	<script type="text/javascript">
	
		$(function(){
			
			var timestampVal = $("#timestamp").val();
			var nonceStrVal = $("#nonceStr").val();
			var signatureVal = $("#signature").val();
			var appId = $("#appId").val();
			
			wx.config({
			    debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
			    appId: appId, // 必填，公众号的唯一标识
			    timestamp: timestampVal, // 必填，生成签名的时间戳
			    nonceStr: nonceStrVal, // 必填，生成签名的随机串
			    signature: signatureVal,// 必填，签名，见附录1
			    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage']
			});
			
			wx.ready(function(){

				wx.onMenuShareTimeline({
				    title: '啊哈', // 分享标题
				    link: 'http://www.baidu.com', // 分享链接
				    imgUrl: '', // 分享图标
				    success: function () { 
						alert("成功分享！");
				    },
				    cancel: function () { 
				       alert("用户取消！");
				    }
				});
			});
			
		});
		
	</script>
</body>
</html>